package Union;

import org.hibernate.Session;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import utils.HibernateUtils;

public class HibernateTest {
	
	private Session session;

	@Before
	public void before() {
		session = HibernateUtils.getSession();
		session.beginTransaction();
	}
	
	@Test
	public void testComponent() {
		//一個人拥有的工资
		Worker worker = new Worker();
		worker.setName("dgw");
		
		Pay pay = new Pay();
		pay.setMonthlyPay(20);
		pay.setVocationWithPay(40);
		pay.setYearPay(1000);
		worker.setPay(pay);
		
		session.save(worker);
	}
	
	@After
	public void after() {
		session.getTransaction().commit();
		session.close();
	}

}
